function [ data ] = improveDataset(dataset_name, baseline_name)

load_settings;

% dataset_name = 'SANDBOX_RUN1';
% baseline_name = 'iter_model';

baseline_mat_location = [trained_root baseline_name '.mat'];

data = getData(dataset_name);
load(baseline_mat_location);
baseline.libsvmmodel = model;
baseline.model = model.w';

%%
for ix = 1:size(data,1)
    for jx = 1:size(data,2)
        if ~isempty(data(ix,jx).cam_id)
            disp(['improveDataset: starting image ' num2str((ix-1)*size(data,2)+jx) ' out of ' num2str(size(data,1)*size(data,2))]);
            test_res = data(ix,jx);
            test_res.bg_rects = [];
            test_res.bg_hogs = [];
            test_res.ppl_rects = [];
            test_res.ppl_hogs = [];
            disp('improveDataset: Starting jitter for ppl rects');
            for kx = 1:size(data(ix,jx).ppl_rects, 1)
                % jitter rectangle
                rect_list = jitterRect(data(ix,jx).ppl_rects(kx,:), jitter_margin, jitter_inc);
                test_res.ppl_rects = rect_list;
                test_res = checkBounds(test_res);
                test_res = computeHogsParallel(test_res, image_root, reshape_size, binsize, hogsize);
                % test all (get decision values) with baseline
                % Question: use dv from new or libsvmnew
                [new, ~] = eval_baseline(baseline, test_res.ppl_hogs, ones(size(test_res.ppl_hogs,1),1), settings);
                [~, index] = max(new.dv);
                % set data(ix,jx).ppl_rects(kx,:) = rect with max dv
                data(ix,jx).ppl_rects(kx,:) = test_res.ppl_rects(index,:);
                data(ix,jx).ppl_hogs(kx,:) = test_res.ppl_hogs(index,:);
                % reset
                test_res.ppl_rects = [];
                test_res.ppl_hogs = [];
            end
        end
    end
end

end
